package com.cheng.cms.controller;

import com.cheng.cms.domain.Parkingfee_info;
import com.cheng.cms.service.ParkingfeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class ParkingfeeController {

    @Autowired
    private ParkingfeeService parkingfeeService;

    @GetMapping("/queryInfo/parkingPayInfo")
    public String parkingPayInfo(ModelMap modelMap){
        List<Parkingfee_info> parkingfeeInfos = parkingfeeService.selectAllParkingFeeInfo();
        modelMap.put("parkingFees",parkingfeeInfos);
        return "queryInfo/parkingPaymentInfo";
    }

    @GetMapping("/queryInfo/parkingPayInfo/condition")
    @ResponseBody
    public List<Parkingfee_info> parkingPayInfoByCondition(String year,String month,String whether){
        Map<String, String> parkingFeeMap = new HashMap<>();
        if(!year.equals("全部")){
            parkingFeeMap.put("buildingNo",year);
        }
        if(!month.equals("全部")){
            parkingFeeMap.put("roomNo",month);
        }
        if(!whether.equals("全部")){
            parkingFeeMap.put("whether",whether);
        }
        return parkingfeeService.selectAllParkingFeeInfoByCondition(parkingFeeMap);
    }

}
